<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span> * @fileoverview The Before Effects SettingsManager module. This module adds methods
<span class='line'>  3</span> * that aid in working with After EFfects settings that would normall be accessed
<span class='line'>  4</span> * through app.settings.
<span class='line'>  5</span> * @author Collin D. Brooks &lt;collin.brooks@gmail.com>
<span class='line'>  6</span> * @version 0.1.0 dev
<span class='line'>  7</span> */</span><span class="WHIT">
<span class='line'>  8</span> 
<span class='line'>  9</span> </span><span class="COMM">//See if BE is already defined</span><span class="WHIT">
<span class='line'> 10</span> </span><span class="NAME">BE</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">BE</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 11</span> 
<span class='line'> 12</span> </span><span class="COMM">/**
<span class='line'> 13</span>  * Provides a way to easily store and retrieve settings that After Effects
<span class='line'> 14</span>  * should save. Settings are automatically saved on &lt;code>set&lt;/code> and loaded
<span class='line'> 15</span>  * on &lt;code>get&lt;/code>.
<span class='line'> 16</span>  * @example
<span class='line'> 17</span>  *   var settingsManager = BE.SettingsManager("My Script Name",
<span class='line'> 18</span>  *       {
<span class='line'> 19</span>  *           "settingOne": "Setting One Value",
<span class='line'> 20</span>  *           "settingTwo": "Setting Two Value"
<span class='line'> 21</span>  *       }
<span class='line'> 22</span>  *   );
<span class='line'> 23</span>  *   settingsManager.get("settingOne");  //"Setting One Value"
<span class='line'> 24</span>  *   settingsManager.set("settingOne", "New Setting One Value");
<span class='line'> 25</span>  *   settingsManager.get("settingOne");  //"New Setting One Value");
<span class='line'> 26</span>  * 
<span class='line'> 27</span>  * @param {String} sectionName The name that After Effects should use as this
<span class='line'> 28</span>  * group of setting's sectionName. This can be the name of your script.
<span class='line'> 29</span>  * @param {Object} settings An Object filled with key/value pairs to be saved
<span class='line'> 30</span>  * within After Effect's settings. If this argument is not provided, settings
<span class='line'> 31</span>  * will need to be added by using the &lt;code>add&lt;code> method.
<span class='line'> 32</span>  * @returns {SettingsManager} A BE.SettingsManager.
<span class='line'> 33</span>  * @constructor
<span class='line'> 34</span>  */</span><span class="WHIT">
<span class='line'> 35</span> 
<span class='line'> 36</span> </span><span class="NAME">BE.SettingsManager</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sectionName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">settings</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT">    </span><span class="NAME">BE.log.debug</span><span class="PUNC">(</span><span class="STRN">"Initializing Settings Manager..."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT">    </span><span class="NAME">BE.log.debug</span><span class="PUNC">(</span><span class="STRN">"sectionName = "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sectionName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="WHIT">    </span><span class="NAME">BE.log.debug</span><span class="PUNC">(</span><span class="STRN">"settings = "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">settings.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 40</span> 
<span class='line'> 41</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">that</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">        </span><span class="NAME">errors</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">            </span><span class="NAME">NO_SETTINGS</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"There are no settings associated with "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">                </span><span class="STRN">"this Settings Manager"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">            </span><span class="NAME">SETTING_DOES_NOT_EXIST</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"Setting does not exist!"</span><span class="WHIT"> 
<span class='line'> 46</span>         </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 47</span> 
<span class='line'> 48</span> </span><span class="WHIT">    </span><span class="NAME">version</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0.1.0 dev"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 50</span>      * The name for After Effects to use as this group of settings' section
<span class='line'> 51</span>      * name.
<span class='line'> 52</span>      * @type {String}
<span class='line'> 53</span>      */</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT">    </span><span class="NAME">this.sectionName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sectionName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 55</span> 
<span class='line'> 56</span> </span><span class="WHIT">    </span><span class="NAME">BE.log.debug</span><span class="PUNC">(</span><span class="STRN">"this.sectionName = "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.sectionName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 57</span> 
<span class='line'> 58</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 59</span>      * The settings Object that contains the settings to be managed by this
<span class='line'> 60</span>      * SettingsManager.
<span class='line'> 61</span>      * 
<span class='line'> 62</span>      * @type {Object}
<span class='line'> 63</span>      */</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">    </span><span class="NAME">this.settings</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">settings</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">settings</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 65</span> 
<span class='line'> 66</span> </span><span class="WHIT">    </span><span class="NAME">BE.log.debug</span><span class="PUNC">(</span><span class="STRN">"this.settings = "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.settings</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 67</span> 
<span class='line'> 68</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 69</span>      * Checks to see if a given setting exists within this SettingsManager.
<span class='line'> 70</span>      * 
<span class='line'> 71</span>      * @param {String} settingName The name of the setting to check for
<span class='line'> 72</span>      * existence.
<span class='line'> 73</span>      * @returns {Bool} True if a given setting exists or false if it doesn't.
<span class='line'> 74</span>      */</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">    </span><span class="NAME">this.settingExists</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">that.settings</span><span class="PUNC">[</span><span class="NAME">settingName</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> 
<span class='line'> 79</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 80</span>      * Checks to see if there aren't any settings associated with this
<span class='line'> 81</span>      * SettingsManager.
<span class='line'> 82</span>      * 
<span class='line'> 83</span>      * @returns {Bool} True if there aren't any settings associated with this
<span class='line'> 84</span>      * SettingsManager or false if there is at least one.
<span class='line'> 85</span>      */</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">    </span><span class="NAME">this.noSettings</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">that.settings.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> 
<span class='line'> 90</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 91</span>      * Saves all of the settings being managed by this SettingsManager. If no
<span class='line'> 92</span>      * settings exists, there is no error; the settings will simply not be
<span class='line'> 93</span>      * saved.
<span class='line'> 94</span>      * 
<span class='line'> 95</span>      * @returns {SettingsManager} The SettingsManager. Useful for chaining.
<span class='line'> 96</span>      */</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">    </span><span class="NAME">this.saveAll</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">that.noSettings</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">        </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">settingName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">            
<span class='line'>102</span>             </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">that.settings</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">            </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">                </span><span class="NAME">that.save</span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">that</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> 
<span class='line'>110</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>111</span>      * Saves the given setting. It is an error if the setting does not exist
<span class='line'>112</span>      * 
<span class='line'>113</span>      * @param {String} [settingName] The setting to save or, if undefined,
<span class='line'>114</span>      * save all settings.
<span class='line'>115</span>      * @throws errors.SETTING_DOES_NOT_EXIST
<span class='line'>116</span>      * @returns {SettingsManager} The SettingsManager. Useful for chaining.
<span class='line'>117</span>      */</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">    </span><span class="NAME">this.save</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">that.settingExists</span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">        </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">            </span><span class="NAME">app.settings.saveSetting</span><span class="PUNC">(</span><span class="NAME">that.sectionName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">settingName</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">                </span><span class="NAME">that.settings</span><span class="PUNC">[</span><span class="NAME">settingName</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">            </span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="NAME">errors.SETTING_DOES_NOT_EXIST</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" Cannot save setting "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">            </span><span class="STRN">"\""</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">settingName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"\" because it does not exist."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">that</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>129</span> 
<span class='line'>130</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>131</span>      * Loads a single setting. It is an error if the given setting does not
<span class='line'>132</span>      * exist.
<span class='line'>133</span>      * 
<span class='line'>134</span>      * @param {String} settingName The name of the setting to load.
<span class='line'>135</span>      * @throws errors.SETTING_DOES_NOT_EXIST
<span class='line'>136</span>      * @returns {SettingsManager} The SettingsManager. Useful for chaining.
<span class='line'>137</span>      */</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">    </span><span class="NAME">this.load</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">that.settingExists</span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">        </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">            </span><span class="NAME">that.settings</span><span class="PUNC">[</span><span class="NAME">settingName</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">                </span><span class="NAME">app.settings.getSetting</span><span class="PUNC">(</span><span class="NAME">that.sectionName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">settingName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">            </span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="NAME">errors.SETTING_DOES_NOT_EXIST</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" Cannot load setting "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">                </span><span class="STRN">"\""</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">settingName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"\" because it does not exist."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">that</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>149</span> 
<span class='line'>150</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>151</span>      * Loads all of the settings being managed by this SettingsManager. It is an
<span class='line'>152</span>      * error if no settings have been registered with this SettingsManager.
<span class='line'>153</span>      * 
<span class='line'>154</span>      * @throws errors.NO_SETTINGS
<span class='line'>155</span>      * @returns {SettingsManager} The SettingsManager. Useful for chaining.
<span class='line'>156</span>      */</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">    </span><span class="NAME">this.loadAll</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">that.settings.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">        </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">            </span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="STRN">"Cannot load all settings because "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">errors.NO_SETTINGS</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>162</span> 
<span class='line'>163</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">settingName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">        
<span class='line'>165</span>         </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">that.settings</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">        </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">            </span><span class="NAME">that.save</span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">that</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>171</span> 
<span class='line'>172</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>173</span>      * Returns the current value of a setting. It is an error if the given
<span class='line'>174</span>      * setting does not exist.
<span class='line'>175</span>      * 
<span class='line'>176</span>      * @param {String} settingName The name of the setting to get the value for.
<span class='line'>177</span>      * @throws errors.SETTING_DOES_NOT_EXIST
<span class='line'>178</span>      * @returns {String} The value of the given setting.
<span class='line'>179</span>      */</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">    </span><span class="NAME">this.get</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">that.settingExists</span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">        </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">            </span><span class="NAME">that.load</span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">that.settings</span><span class="PUNC">[</span><span class="NAME">settingName</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">            </span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="NAME">errors.SETTING_DOES_NOT_EXIST</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" Cannot get setting "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">                </span><span class="STRN">"\""</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">settingName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"\" because it does not exist."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>189</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>190</span> 
<span class='line'>191</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>192</span>      * Sets a setting value. If a setting doesn't exist, the setting is created.
<span class='line'>193</span>      * 
<span class='line'>194</span>      * @returns {SettingsManager} The SettingsManager. Useful for chaining.
<span class='line'>195</span>      */</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">    </span><span class="NAME">this.set</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">settingValue</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">        </span><span class="NAME">that.settings</span><span class="PUNC">[</span><span class="NAME">settingName</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">settingValue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">        </span><span class="NAME">that.save</span><span class="PUNC">(</span><span class="NAME">settingName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">that</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>201</span> 
<span class='line'>202</span> </span><span class="WHIT">    </span><span class="NAME">BE.log.debug</span><span class="PUNC">(</span><span class="STRN">"Returning ScriptManager Version: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.version</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>204</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>205</span> </span></pre></body></html>